/*
 * inotify-sync - a simple file synchronizer and file system watcher
 * Copyright (C) 2010-2011, inotify-sync developers and inotify-sync contributors
 * Copyright (C) 2010-2011, Cohesion Network Security Studio
 *
 * inotify-sync is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * inotify-sync is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with inotify-sync; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

/**
 * @file	ProfileXml.h
 * @author	h2s
 * @date	2011-02-15
 * @remarks	Singleton Pattern
 */

#ifndef PROFILEXML
#define PROFILEXML

#include <libxml/parser.h>
#include <libxml/tree.h>
#include <string>
#include <sstream>
#include <vector>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>

#include "Profile.h"
#include "Error.h"
#include "Converter.h"

using namespace std;

extern Converter Conv;

class ProfileXml
{
public:
	ProfileXml(string profile_path);
	virtual ~ProfileXml();

	bool add_profile(Profile& profile);
	bool has_profile(string profile_name);
	bool delete_profile(string profile_name);
	void delete_all_profile();
	void get_profile_list(vector<string>& svec);
	bool get_profile(Profile& profile);
#ifndef UT
protected:
#endif

#ifndef UT
private:
#endif
	xmlNodePtr get_profile_node(string profile_name);
	const char* y_or_n(bool val);
	bool y_or_n2(xmlChar *val);

	string profile_path;
	xmlDocPtr p_doc;
	xmlNodePtr p_root_node;
	xmlNodePtr p_cur_node;
};

#endif
